package services.impl;

import java.sql.SQLException;
import java.util.List;

import dao.AdressDao;
import dao.impl.AdressDaoImpl;
import entity.Adress;

import services.AddressService;

public class AddressServiceImpl implements AddressService{
    AdressDao adDao=new AdressDaoImpl();
	@Override
	public int InsertIntoAddress(int user_id, String adress) {
		int res = 0;
		try {
			res = adDao.addAdress(user_id, adress);
			if(res > 0) return res;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return res;
	}
	@Override
	public int updateuserAdress(int user_id, String adress) {
		int res = 0;
		try {
			res = adDao.updataAdress(user_id, adress);
			if(res > 0) return res;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return res;
	}
	@Override
	public List<Adress> getuserAllAdress(int user_id){

		List<Adress> adressList = null;
		try {
			adressList = adDao.userAdress(user_id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return adressList;
		
		
		
	}
	@Override
	public int dealuserAdress(int adress_id) {
		int res = 0;
		try {
			res = adDao.delOneAdress(adress_id);
			
			if(res > 0) return res;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return res;
	}
	
	
	
	
	
	
	
	

}
